﻿
/**********************************************************/
/* 信息展示菜单
/**********************************************************/

var store = Ext.create('Ext.data.TreeStore', {
    proxy: {
        type: 'ajax',
        url: 'MainForm.aspx?action=TreeMenu&parentid=system'
    },
    root: {
        text: '',
        id: 'src',
        expanded: true
    },
    folderSort: true,
    sorters: [{
        property: 'text',
        direction: 'ASC'
    }]
});
var tree = Ext.create('Ext.tree.Panel', {
    id: 'tree',
    rootVisible: false,
    store: store,
    border:0,
    width: 250,
    height: 300,
    viewConfig: {
        plugins: {
            ptype: 'treeviewdragdrop',
            appendOnly: true
        }
    },
    listeners: {
        itemclick: function (a, node, b, c) {
            var tab = Ext.getCmp(node.data.id);
            if (!tab) {
                var tab = center.add({
                    id: node.data.id,
                    iconCls: node.data.iconCls,
                    title: node.data.text,
                    closable: true,
                    layout: "fit",
                    html: "<iframe src='" + node.data.qtip + "' scrolling='no' frameborder=0 width=100% height=100%></iframe>"

                });
            }
            center.setActiveTab(tab);
        },
        dblclick: {
            element: 'body', 
            fn: function () { console.log('dblclick body'); }
        }
    }
});


/**********************************************************/
/* 信息展示菜单
/**********************************************************/
var store1 = Ext.create('Ext.data.TreeStore', {
    proxy: {
        type: 'ajax',
        url: 'MainForm.aspx?action=TreeMenu&parentid=vipreg'
    },
    root: {
        text: '',
        id: 'src',
        expanded: true
    },
    folderSort: true,
    sorters: [{
        property: 'text',
        direction: 'ASC'
    }]
});
var tree1 = Ext.create('Ext.tree.Panel', {
    id: 'tree1',
    rootVisible: false,
    store: store1,
    border: 0,
    width: 250,
    height: 300,
    viewConfig: {
        plugins: {
            ptype: 'treeviewdragdrop',
            appendOnly: true
        }
    },
    listeners: {
        itemclick: function (a, node, b, c) {
            var tab = Ext.getCmp(node.data.id);
            if (!tab) {
                var tab = center.add({
                    id: node.data.id,
                    iconCls: node.data.iconCls,
                    title: node.data.text,
                    closable: true,
                    layout: "fit",
                    html: "<iframe src='" + node.data.qtip + "' scrolling='no' frameborder=0 width=100% height=100%></iframe>"

                });
            }
            center.setActiveTab(tab);
        },
        dblclick: {
            element: 'body', 
            fn: function () { console.log('dblclick body'); }
        }
    }
});

/**********************************************************/
/* 设置
/**********************************************************/
var store2 = Ext.create('Ext.data.TreeStore', {
    proxy: {
        type: 'ajax',
        url: 'MainForm.aspx?action=TreeMenu&parentid=setting'
    },
    root: {
        text: '',
        id: 'src',
        expanded: true
    },
    folderSort: true,
    sorters: [{
        property: 'text',
        direction: 'ASC'
    }]
});
var tree2 = Ext.create('Ext.tree.Panel', {
    id: 'tree2',
    rootVisible: false,
    store: store2,
    border: 0,
    width: 250,
    height: 300,
    viewConfig: {
        plugins: {
            ptype: 'treeviewdragdrop',
            appendOnly: true
        }
    },
    listeners: {
        itemclick: function (a, node, b, c) {
            var tab = Ext.getCmp(node.data.id);
            if (!tab) {
                var tab = center.add({
                    id: node.data.id,
                    iconCls: node.data.iconCls,
                    title: node.data.text,
                    closable: true,
                    layout: "fit",
                    html: "<iframe src='" + node.data.qtip + "' scrolling='no' frameborder=0 width=100% height=100%></iframe>"

                });
            }
            center.setActiveTab(tab);
        },
        dblclick: {
            element: 'body',
            fn: function () { console.log('dblclick body'); }
        }
    }
});
